package com.mms.util;
import org.hibernate.Session; 
import org.hibernate.SessionFactory; 
import org.hibernate.cfg.Configuration; 

public class HibernateUtil { 
     private static Configuration configuration; 
     private static SessionFactory sessionFactory; 
     static { 
         try { 
             configuration = new Configuration(); 
             configuration.configure("hibernate.cfg.xml"); 
             sessionFactory = configuration.buildSessionFactory(); 
         } catch (Throwable ex) { 
             throw new ExceptionInInitializerError(ex); 
         } 
     } 
     public static Session getSession(){ 
    return sessionFactory.openSession(); 
     } 
} 